<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=10">
    <link rel="shortcut icon" href="/static/favicon.ico?v=1" type="image/vnd.microsoft.icon"/>
    <title>Foundry</title>
    <script id="sap-ui-bootstrap"
            src="/static/js/libs/OpenUI5/sap-ui-core.js"
            data-sap-ui-language="en"
            data-sap-ui-libs="sap.m"
            data-sap-ui-theme="sap_bluecrystal"
            data-sap-ui-xx-bindingSyntax="complex"
            data-sap-ui-preload="async"
            data-sap-ui-compatVersion="edge"
            data-sap-ui-resourceroots='{"sap.m.bbf41.Module": "/static/js/app/Foundry/"}'
            data-sap-ui-frameOptions="trusted">
    </script>
    <script>
        var myFormatter = {
            setBackgroundColor: function (sValue, Type, o) {
                var isValidValue = Math.abs(sValue) >= 0,
                    className = 'backgroundGreen',
                    needRemoveClass = false;
                var id = this.getId();
                var $elm = $('#' + id);

                $elm.closest('td').removeClass('backgroundRed backgroundGreen');
                if (isValidValue && Type != null) {
                    switch (Type) {
                        case 'Target':
                        case 'Planned':
                            className = '';
                            needRemoveClass = true;
                            break;
                        case 'Deviation':
                            if (sValue < 0) {
                                className = 'backgroundRed';
                            }
                            break;
                        case 'Current':
                            var field = this.data('Field');
                            if (field && o[3][field] && sValue < o[3][field]) {
                                className = 'backgroundRed';
                            }
                            break;
                        case 'Forecast':
                            var field = this.data('Field');
                            if (field && o[0][field] && sValue < o[0][field]) {
                                className = 'backgroundRed';
                            }
                            break;
                    }
                    if (className) {
                        $elm.closest('td').addClass(className);
                    }
                }
                return sValue;
            },
            setTableHeaderBackground: function(sValue, ShiftNum) {
                var sBackgroundColor = '';
                if (sValue && (sValue == 'Shift ' + ShiftNum)) {
                    sBackgroundColor = 'backgroundBlue';
                }
                if(sBackgroundColor) {
                    var id = this.getId();
                    var $elm = $('#' + id);
                    $elm.closest('td').addClass(sBackgroundColor);
                }
                return sValue;
            }
        };
        sap.ui.getCore().attachInit(function () {
            sap.ui.require([
                "sap/m/Shell",
                "sap/ui/core/ComponentContainer"
            ], function (Shell, ComponentContainer) {
                // initialize the UI component
                new Shell({
                    app: new ComponentContainer({
                        height: "100%",
                        name: "sap.m.bbf41.Module"
                    })
                }).placeAt("content");
            });
        });
    </script>
</head>
<!-- UI Content -->
<body class="sapUiBody" role="application">
    <div id="content"></div>
</body>
</html>
